package com.qiaoan.back.controller.sys;

import com.qiaoan.back.controller.BaseController;
import com.qiaoan.back.model.sys.MenuModel;
import com.qiaoan.back.service.sys.MenuService;
import com.qiaoan.back.service.sys.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author zhang_chong521
 *
 */
@Controller
@RequestMapping("/login")
public class LoginController extends BaseController {
	
	@Autowired
	private UserService userService ;

	@Autowired
	private MenuService menuService ;

	
	@RequestMapping(value = "/togo", method = { RequestMethod.GET })
	public String togo(Model model, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		
		return "login";
		
	}
	
	@RequestMapping(value = "/login", method = { RequestMethod.GET })
	public String login(Model model, HttpServletRequest request,
					   HttpServletResponse response) throws Exception {

		return "login";

	}

	@RequestMapping(value = "/index", method = { RequestMethod.GET })
	public String index(Model model, HttpServletRequest request,
						HttpServletResponse response) throws Exception {
		//获取全部的菜单
		List<MenuModel> menuTree = menuService.getAllMenus(1);
		model.addAttribute("menuTree",menuTree);

		return "welcome";

	}

}
